
<style type="text/css">
#order_list_search_bar{width:894px; margin: 0 auto 25px; overflow: auto; padding:25px; border: 3px solid #f3f3f3;}
#order_list_search_bar ul{list-style:none;}
#order_list_search_bar ul li{display: block; margin-bottom: 10px; margin-bottom: 20px;}
#order_list_search_bar ul li label{display:inline-block; width: 150px; text-align: right;}
#order_list_search_bar .search_bar_sub_bar{margin-top:10px;  text-align: right;}
#order_list_search_bar .search_field_order_sn{width: 680px; border:2px solid #ccc;}
#order_list_search_bar select{padding-left: 10px; padding-right: 50px; appearance: none; -moz-appearance: none; -webkit-appearance: none;}
.arrow-down{position:relative; left: -55px; top:-5px;  display: inline-block; border: solid black; border-width: 0 3px 3px 0; padding: 7.5px; margin-right: 12.5px; margin-left: 12.5px; transform: rotate(45deg); -webkit-transform: rotate(45deg);
}

#orderListDiv{width:950px; margin: 25px auto; overflow: auto;}
#orderListDiv .order_info_div{margin-bottom: 25px; overflow: auto;}
#orderListDiv table{width:100%; text-align:left; border-collapse: collapse;}
#orderListDiv table th, #orderListDiv table td{padding:12.5px; text-align:left; vertical-align:top; /* border: 1px solid #ccc; */ border: 3px solid #f3f3f3;}

#orderListDiv table.order_info_table{border-top: 5px solid #ccc; /* overflow: auto; */}
#orderListDiv table td.orderTotalPrice{width:250px; color:#F30;}
#orderListDiv table td.order_status_desc_td{width:90px;}
#orderListDiv table td.orderAction{width:210px;}
#orderListDiv table td.orderAction .order_action_button{padding:3px 5px; color:#fff; background:#06f;}

#orderListDiv table.order_list_good_table th{border-top:none;}
#orderListDiv table.order_list_good_table{margin-top: -5px; /* overflow: auto; */}
#orderListDiv table.order_list_good_table td.goodTd{/* width:554px; */}
#orderListDiv table.order_list_good_table td .goodThumbDiv{/* float:left; */ width:200px; height: 200px;}
#orderListDiv table.order_list_good_table td .goodThumbDiv a{ width:200px; height: 200px;}
#orderListDiv table.order_list_good_table td .goodThumbDiv a img{width:200px; height: 200px;}
#orderListDiv table.order_list_good_table td .goodTitleAttrDiv{/* float:left; */ width:380px; /* height: 80px; */}
/* #orderListDiv table.order_list_good_table td .goodTitleAttrDiv p{padding-top:12.5px;} */
#orderListDiv table.order_list_good_table td .goodTitleAttrDiv p.goodTitle{padding-top:12.5px;}
#orderListDiv table.order_list_good_table td .goodTitleAttrDiv p.goodAttr{padding-top:12.5px; color:#999;}


#orderListDiv .paginationControl{clear:both; float:right; padding:10px 0;}
/*#orderListDiv .paginationControl a:link{text-decoration:underline;}*/
#orderListDiv .paginationControl a{text-decoration:underline;}
</style>

<div id="order_list_search_bar">
    <form id="order_list_search_form" onsubmit="return search_order_list();" action="<?php echo $this->get_url(array('page_num' => 1)); ?>" method="get">

        <ul class="search_field">
            <li>
                <label>订单编号：</label>
                <input class="search_field_order_sn" type="text" name="order_sn" maxlength="100" value="<?php echo $view_data['order_sn']; ?>">
            </li>
            <li>
				<label>状态：</label>
                <select name="status">

                    <option value="10" <?php if($view_data['status'] == 10): ?>selected="selected"<?php endif; ?>>全部</option>

                    <option value="0" <?php if($view_data['status'] == 0): ?>selected="selected"<?php endif; ?>>待付款</option>
                    <option value="1" <?php if($view_data['status'] == 1): ?>selected="selected"<?php endif; ?>>已付款</option>
                    <option value="2" <?php if($view_data['status'] == 2): ?>selected="selected"<?php endif; ?>>待收货</option>
                    <option value="3" <?php if($view_data['status'] == 3): ?>selected="selected"<?php endif; ?>>已收货</option>

                    <?php /* <option value="-1" <?php if($view_data['status'] == -1): ?>selected="selected"<?php endif; ?>>已失效</option> */ ?>
                    <option value="-2" <?php if($view_data['status'] == -2): ?>selected="selected"<?php endif; ?>>已退货</option>
                </select>
                <i class="arrow-down"></i>
			</li>
        </ul>

        <div class="search_bar_sub_bar">
            <!-- <input type="hidden" name="page_num" value="1"/> -->
            <input class="input_submit" type="submit" value="搜索" />
        </div>
    </form>
</div>


<div id="orderListDiv">
	<?php foreach ($view_data['order_list'] as $index => $order_info): ?>
    <div class="order_info_div">
        <table class="order_info_table">
            <thead>
                <tr <?php if(($index+1)%2 == 0): ?>class="orderEven" <?php endif; ?>>
                    <td colspan="4">订单编号：<a href="<?php echo $this->get_url(array('route' => 'order_info', 'id' => $order_info['id']), true); ?>" target="_blank"><?php echo $order_info['order_sn']; ?></a></td>
                </tr>
                <tr <?php if(($index+1)%2 == 0): ?>class="orderEven" <?php endif; ?>>
                    <th>金额</th>
                    <th>状态</th>
                    <th>下单时间</th>
                    <th>操作</th>
                </tr>
            </thead>

            <tbody>

                <tr id="order-<?php echo $order_info['id']; ?>" <?php if(($index+1)%2 == 0): ?>class="orderEven" <?php endif; ?>>
                    <td class="orderTotalPrice">￥ <?php echo $order_info['order_total_price']; ?></td>
                    <td id="orderStatusTd-<?php echo $order_info['id']; ?>" class="order_status_desc_td"><?php echo $order_info['status_desc']; ?></td>
                    <td><?php echo $order_info['create_time_date_time']; ?></td>
                    <td class="orderAction">
                        <a class="order_action_button" id="orderView-<?php echo $order_info['id']; ?>" href="<?php echo $this->get_url(array('route' => 'order_info', 'id' => $order_info['id']), true); ?>" target="_blank">查看</a>
                        <?php if($order_info['status'] == 2): ?>
                        <a class="order_action_button" id="confirmReceive-<?php echo $order_info['id']; ?>" href="javascript:void(0);" onclick="confirmReceive('<?php echo $order_info['id']; ?>');">确认收货</a>
                        <?php endif; ?>
                    </td>
                </tr>

            </tbody>
        </table>

        <table class="order_list_good_table">
            <thead>
                <tr <?php if(($index+1)%2 == 0): ?>class="orderEven" <?php endif; ?>>
                    <th>商品</th>
                    <th>价格</th>
                    <th>数量</th>
                    <th>小计</th>
                </tr>
            </thead>

            <tbody>
            <?php foreach ($view_data['order_list_good'][$order_info['id']] as $item): ?>
                <tr <?php if(($index+1)%2 == 0): ?>class="orderEven" <?php endif; ?>>
                    <td class="goodTd">
                        <div class="goodThumbDiv">
                            <a title="<?php echo $item['good_name']; ?>" target="_blank" href="<?php echo $this->get_url(array('route' => 'good_info', 'id' => $item['good_id']), true); ?>">
                                <img class="goodThumb" height="80" width="80" alt="<?php echo $item['good_name']; ?>" src="<?php echo $item['good_thumb']; ?>">
                            </a>
                        </div>
                        <div class="goodTitleAttrDiv">
                            <p class="goodTitle"><a href="<?php echo $this->get_url(array('route' => 'good_info', 'id' => $item['good_id']), true); ?>" target="_blank" ><?php echo $item['good_name']; ?></a></p>
                            <p class="goodAttr"><?php echo $item['spec_desc']; ?></p>
                        </div>
                    </td>
                    <td><?php echo $item['good_price']; ?></td>
                    <td><?php echo $item['good_number']; ?></td>
                    <td><?php echo $item['item_total_price']; ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <?php endforeach; ?>

    <?php echo $view_data['page_lib_output']; ?>
</div>

<script type="text/javascript">
function search_order_list(){
    var order_sn = $("#order_list_search_form input[name='order_sn']").val();
    var status = $("#order_list_search_form select[name='status']").val();

    var url_params_json = <?php echo $this->get_url_params_json(); ?>;
    url_params_json['page_num'] = 1;
    url_params_json['order_sn'] = order_sn;
    url_params_json['status'] = status;
    var url = wwy_get_url(url_params_json);

    window.top.location.replace(url);

    return false;
}

function confirmReceive(id){
	//if(confirm('请在收到货后才进行确认收货！确认收货？')){
    confirm_prompt_message('请在收到货后才进行确认收货！确认收货？', function(){
		$.ajax({
			type: 'POST',
			url: '<?php echo $this->get_url(array('route' => 'order_confirm_receive'), true); ?>',
			data: 'id=' + id,
			dataType: 'json',
			success: function(rdata){			
				if(rdata.status <= 0){
					//alert(rdata.message);
                    show_prompt_message(rdata.message);
				}else{
					//alert(rdata.message);
                    show_prompt_message(rdata.message);
					$('#orderStatusTd-' + id).html('已收货');
					$('#confirmReceive-' + id).remove();
				}	
				
				return false;	
			}
		});
	//}
    });

	return false;
}
</script>